import { createApp } from "vue"
import router from "./router"
import "./style.css"
import App from "./App.vue"
import axios from "./utils/request.js"
import ElementPlus from "element-plus"
import "element-plus/dist/index.css"
import * as echarts from "echarts"
import { createPinia } from "pinia"
import "animate.css"
import IotCryptoJS from "./utils/IotCryptoJS"
import { regAllDirectives } from "@/directives/index.js" // 全局指令导入
// 创建 pinia 对象
const pinia = createPinia()
const MainApp = createApp(App)
regAllDirectives(MainApp) // 将App传入全局指令
MainApp.use(router).use(pinia).use(ElementPlus).mount("#app")
MainApp.config.globalProperties.$axios = axios
MainApp.config.globalProperties.$echarts = echarts
MainApp.config.globalProperties.$IotCryptoJS = IotCryptoJS
MainApp.config.globalProperties.fontSize = function (val) {
  let clientWidth = document.body.clientWidth
  let value = (val * clientWidth) / 1200
  return value
}
MainApp.config.globalProperties.setstartTime = (time) => {
  const date = new Date(time)
  const year = date.getFullYear()
  const month = String(date.getMonth() + 1).padStart(2, "0")
  const day = String(date.getDate()).padStart(2, "0")
  const hours = String(date.getHours()).padStart(2, "0")
  const minutes = String(date.getMinutes()).padStart(2, "0")
  const s = date.getSeconds().toString().padStart(2, "0") // 秒

  return { year, month, day, hours, minutes, s }
}
